/* eslint valid-jsdoc: "off" */

'use strict';

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
    /**
     * built-in config
     * @type {Egg.EggAppConfig}
     **/
    const config = exports = {};

    // use for cookie sign key, should change to your own and keep security
    config.keys = appInfo.name + '_1677120789627_4920';

    // add your middleware config here
    config.middleware = ['errorHandler', 'auth', 'admin', 'xmlparse'];

    config.auth = {
        ignore: ['/user/reg', '/user/login', '/ws', '/user/getCode', '/m', '/config', '/m/consultation', '/config/h5paySubmit']
    };
    config.admin = {
        ignore: ['/user', '/m/adminUser/login', '/config', '/m/consultation']
    };
    config.multipart = {
        mode: 'file',
        whitelist: [
            '.jpg', '.jpeg', // image/jpeg
            '.png', // image/png, image/x-png
            '.gif', // image/gif
            '.bmp', // image/bmp
            '.wbmp', // image/vnd.wap.wbmp
            '.webp',
            '.tif',
            '.xls', '.xlsx',
            '.psd',
            // text
            '.svg',
            '.js', '.jsx',
            '.json',
            '.css', '.less',
            '.html', '.htm',
            '.xml',
            // tar
            '.zip',
            '.gz', '.tgz', '.gzip',
            // video
            '.mp3',
            '.mp4',
            '.avi',
            '.txt',
            '.ogg'
        ]
    };

    // add your user config here
    const userConfig = {
        // myAppName: 'egg',
    };
    config.security = {
        // 关闭 csrf
        csrf: {
            enable: false,
        },
        // 跨域白名单
        domainWhiteList: ['http://localhost:3000'],
    };
    // 允许跨域的方法
    config.cors = {
        origin: '*',
        allowMethods: 'GET, PUT, POST, DELETE, PATCH'
    };
    config.sequelize = {
        dialect: 'mysql',
        host: '127.0.0.1',
        username: 'root',
        password: '123456',
        port: 3306,
        database: 'egg-psychology',
        // 中国时区
        timezone: '+08:00',
        define: {
            // 取消数据表名复数
            freezeTableName: true,
            // 自动写入时间戳 created_at updated_at
            timestamps: true,
            // 字段生成软删除时间戳 deleted_at
            // paranoid: true,
            createdAt: 'created_at',
            updatedAt: 'updated_at',
            // deletedAt: 'deleted_at', 
            // 所有驼峰命名格式化
            underscored: true
        }
    };

    config.valparams = {
        locale: 'zh-cn',
        throwError: true
    };
    config.crypto = {
        secret: 'qhdgw@45ncashdaksh2!#@3nxjdas*_672why'
    };

    config.jwt = {
        secret: 'qhdgw@45ncashdaksh2!#@3nxjdas*_672'
    };

    // redis存储
    config.redis = {
            client: {
                port: 6379, // Redis port
                host: '127.0.0.1', // Redis host
                password: '123456',
                db: 15,
            },
        }
        //oss存储
    config.oss = {
            client: {
                accessKeyId: 'LTAI5tHX6gTZeAiVemVNkmkS',
                accessKeySecret: 'xImF5ZiPcsaFnd7vi2fnF24EYsMtmt',
                bucket: 'why0412',
                endpoint: 'oss-cn-hangzhou.aliyuncs.com',
                timeout: '60s',
            },
        },
        config.sms = {
            client: {
                accessKeyId: 'LTAI5tHX6gTZeAiVemVNkmkS', //阿里云的
                secretAccessKey: 'xImF5ZiPcsaFnd7vi2fnF24EYsMtmt' //阿里云的
            }
        }
    config.webUrl = 'http://127.0.0.1:7001'
        // 微信支付配置（最好改成你自己的）
    config.tenpay = {
        client: {
            appid: 'wx6516e82669c2fe16',
            mchid: '1641829205',
            partnerKey: '342706709xdxl342706709xdxl342706',
            notify_url: config.webUrl + '/config/notify',
            // sandbox: true
        }
    };
    // config.cluster = {
    //     listen: {
    //         path: '',
    //         port: 8000,
    //         hostname: '127.0.0.1',
    //     }
    // };

    return {
        ...config,
        ...userConfig,
    };
};